package com.ruoyi.project.business.syscity.controller;

import java.util.List;

import com.ruoyi.project.business.socialsecurity.request.FindLikeCityNameRequest;
import com.ruoyi.project.business.socialsecurity.response.SysSocialSecurityResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.business.syscity.entity.SysCity;
import com.ruoyi.project.business.syscity.request.ListSysCityRequest;
import com.ruoyi.project.business.syscity.request.AddSysCityRequest;
import com.ruoyi.project.business.syscity.response.SysCityResponse;
import com.ruoyi.project.business.syscity.service.ISysCityService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.model.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ${author}
 * @date 2024-03-19
 */
@RestController
@RequestMapping("/business/syscity")
public class SysCityController extends BaseController {
    @Autowired
    private ISysCityService sysCityService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('business:syscity:list')")
    @GetMapping("/list")
    public TableDataInfo list(ListSysCityRequest request) {
        startPage();
        
        List<SysCityResponse> list = sysCityService.selectSysCityList(request);
        return getDataTable(list);
    }


    /**
     * 查询平台级每年社保基数维护列表
     */
    @GetMapping("/list-like-name")
    public TableDataInfo listLikeName(FindLikeCityNameRequest request) {
        startPage();
        List<SysCityResponse> list = sysCityService.selectListLikeName(request);
        return getDataTable(list);
    }
    

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('business:syscity:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ListSysCityRequest request) {
        
        List<SysCityResponse> list = sysCityService.selectSysCityList(request);
        ExcelUtil<SysCityResponse> util = new ExcelUtil<>(SysCityResponse.class);
        return util.exportExcel(list, "syscity");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:syscity:query')")
    @GetMapping(value = "/{code}")
    public AjaxResult getInfo(@PathVariable("code") String code) {
        return AjaxResult.success(sysCityService.selectSysCityById(code));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('business:syscity:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AddSysCityRequest request) {
        
        Long operatorId = getUserId();
        return toAjax(sysCityService.insertSysCity(request, operatorId));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('business:syscity:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCity sysCity) {
        
        Long operatorId = getUserId();
        return toAjax(sysCityService.updateSysCity(sysCity, operatorId));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('business:syscity:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{codes}")
    public AjaxResult remove(@PathVariable String[] codes) {
        
        Long operatorId = getUserId();
        return toAjax(sysCityService.deleteSysCityByIds(codes, operatorId));
    }
}
